package com.googlecode.hmvc4gwt.framework.client.module;

import com.google.gwt.user.client.History;
import com.googlecode.hmvc4gwt.client.events.in.AddRootPanelViewEvent;
import com.googlecode.hmvc4gwt.client.events.in.RemoveRootPanelViewEvent;
import com.googlecode.hmvc4gwt.client.module.AModuleControllerRootPanel;
import com.googlecode.hmvc4java.event.IEvent;
import com.googlecode.hmvc4java.registry.eventregistry.EventRegsitryController;
import com.googlecode.hmvc4java.registry.eventregistry.events.in.AddEventRegistryListenerEvent;

public abstract class AModuleControllerRootPanelRegisty extends AModuleControllerRootPanel implements IModuleControllerRegistry {

	@Override
	public void init() {
		/*
		 * registering the ModuleController as an HistoryListener
		 */
		History.addValueChangeHandler(this);
		
		/*
		 * listen to StartArtifacEvent's
		 */
		fireEventGlobal(new AddEventRegistryListenerEvent(AddRootPanelViewEvent.class,
				this));
		fireEventGlobal(new AddEventRegistryListenerEvent(RemoveRootPanelViewEvent.class,
				this));
		
		super.init();
	}

	public final void fireEventGlobal(IEvent event) {
		EventRegsitryController.fireEventGlobal(event);
	}

}
